<?php

namespace AppBundle\EventSubscriber;

use AppBundle\Common\Log;
use AppBundle\Event\OrderEvent;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;

/**
 * Class OrderEventSubscriber
 */
class OrderEventSubscriber implements EventSubscriberInterface
{
    public $signal = 0;

    public static function getSubscribedEvents()
    {
        // here we are going to listen to the event "order.finish" event
        // and if we do, we'll use the method sendEmailToAdmin()
        return array(
            "order.create" => array(
                array('createOrder', 10)
            )
        );
    }

    public function createOrder(OrderEvent $orderEvent)
    {
        // náš kód, který pošle e-mail adminovi
        // $this->signal = 1;
        $this->signal = $orderEvent->getOrderId();
        Log::log($orderEvent->getOrderId());
    }
}